<template>
  <div>
    <!-- //分页器封装文件 -->
    <el-pagination
      :current-page="page"
      :page-sizes="pageSizes"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      v-bind="$attrs"
      @size-change="sizeChange"
      @current-change="currentChange"
    />
  </div>
</template>

<script>
export default {
  name: "Paging",
  // 子组件接收父组件的值
  props: {
    page: {
      required: true,
      type: Number,
      default: 1,
    },
    total: {
      type: Number,
      required: false,
      default: 0,
    },
    pagesize: {
      type: Number,
      required: false,
      default: 10,
    },
  },
  data() {
    return {
      pageSizes: [5, 10, 15, 20], // 每页显示多少条
    };
  },
  // 事件方法
  methods: {
    // 每页展示几条变化
    sizeChange(newPage) {
      // 子组件向父组件传值
      this.$emit("sizeChange", newPage);
    },
    // 页码变化
    currentChange(newpageSize) {
      // 子组件向父组件传值
      this.$emit("currentChange", newpageSize);
    },
  },
};
</script>
